<?php

class ArticleType extends Mysql {
	public function __construct() {
		parent::__construct();
	}
	public function queryById($id) {
		if (empty($id) || ltrim($id)=='') {
			$id = -1;
		}
		$sql = "select * from articletype where id = $id;";
		$rows = $this->exec_query($sql);
		if ($rows && count($rows) > 0) {//返回第一个类型
			return $rows[0];
		}
		return false;
	}
	/**
	 * 根据文章type查询所有文章 类型分页
	 * 2012-5-2 上午10:49:26
	 * Xewee.Zhiwei.Wang
	 */
	public function query() {
		$sql = "select * from  articletype order by time desc;";
		$rows = $this->exec_query($sql);
		return $rows;
	}
	
	/**
	 * 根据文章type查询所有文章 类型分页
	 * 2012-5-2 上午10:49:26
	 * Xewee.Zhiwei.Wang
	 */
	public function queryInfo() {
		$sql = "select id, time, name, sort, num from articletype left join (select typeId, count(id) as num from article where deleted='0' group by typeId) t on articletype.id = t.typeid order by sort desc;";
		$rows = $this->exec_query($sql);
		return $rows;
	}
}

?>